/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jjsoft.celularessuc.gco.ui;

import com.jjsoft.celularessuc.gco.mdl.Cliente;
import com.jjsoft.celularessuc.gco.mdl.Serviciotecnico;
import com.jjsoft.celularessuc.gco.mdl.Usuario;
import com.jjsoft.celularessuc.gco.neg.CImprimir;
import com.jjsoft.celularessuc.gco.neg.ServicioTecnicoManager;
import com.jjsoft.celularessuc.gco.neg.UsuarioManager;
import com.jjsoft.celularessuc.gco.util.Validacion;
import com.jjsoft.celularessuc.gco.util.configuraciones;
import java.awt.GridLayout;
import java.util.Date;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;

/**
 *
 * @author johnny
 */
public class VServicioTecnico extends javax.swing.JFrame {

    /**
     * Creates new form VServicioTecnico
     */
    Cliente cli;
    Date d = new Date();
    int numero = 0;
    Serviciotecnico Servicio;
    JTextField texto;
    ServicioTecnicoManager stm = new ServicioTecnicoManager();
    //Using a JPanel as the message for the JOptionPane
    JPanel userPanel = new JPanel();

//Labels for the textfield components        
    JLabel usernameLbl = new JLabel("Usuario:");
    JLabel passwordLbl = new JLabel("Password:");

    JTextField username = new JTextField();
    JPasswordField passwordFld = new JPasswordField();

    public VServicioTecnico(Cliente cli) {
        this.setIconImage(new javax.swing.ImageIcon(getClass().getResource("/img/1362798841_CellPhone.png")).getImage());
        initComponents();
        this.cli = cli;
        txtCedula.setText(cli.getCedula());
        txtCliente.setText(cli.getNombres() + " " + cli.getApellidos());
        txtFecha.setText(d.toLocaleString());
        txtTelefono.setText(cli.getTelefono());
        
        //txtNumero.setText(String.valueOf(stm.buscaNumero()));
        lblCosto.setVisible(false);
        txtCosto.setVisible(false);
        lblDevuelto.setVisible(false);
        cmdEntregar.setVisible(false);
        cmdAnular.setVisible(false);
        Servicio = new Serviciotecnico();
        userPanel.setLayout(new GridLayout(2, 2));
        cmdImprimir.setVisible(false);
//Labels for the textfield components        
//Add the components to the JPanel        
        userPanel.add(usernameLbl);
        userPanel.add(username);
        userPanel.add(passwordLbl);
        userPanel.add(passwordFld);
    }

    public VServicioTecnico(Serviciotecnico serv) {
        this.setIconImage(new javax.swing.ImageIcon(getClass().getResource("/img/1362798841_CellPhone.png")).getImage());
        initComponents();
        this.Servicio = serv;
        txtCedula.setText(serv.getCedulaCliente().getCedula());
        txtCliente.setText(serv.getCedulaCliente().getNombres() + " " + serv.getCedulaCliente().getApellidos());
        txtFecha.setText(serv.getFecha().getDate() + "-" + (serv.getFecha().getMonth() + 1) + "-" + (serv.getFecha().getYear() + 1900));
        txtChip.setText(serv.getChip());
        txtDatos.setText(serv.getDatos());
        txtFallo.setText(serv.getFallo());
        txtMemoria.setText(serv.getMemoria());
        txtNumSerie.setText(serv.getNumeroSerie());
        txtNumero.setText(serv.getIdServicioTecnico().toString());
        txtObservaciones.setText(serv.getObservaciones());
        txtCosto.setText(serv.getPaga().toString());
        txtChip.setEditable(false);
        txtDatos.setEditable(false);
        txtFallo.setEditable(false);
        txtMemoria.setEditable(false);
        txtNumSerie.setEditable(false);
        txtNumero.setEditable(false);
        txtObservaciones.setEditable(false);
        cmdCancelar.setText("Salir");
        cmdGuardar.setVisible(false);
        cmdImprimir.setVisible(true);
        if (!serv.getIdSucursal().equals(configuraciones.getInstance().getSucursal())) {
            cmdAnular.setEnabled(false);
            cmdEntregar.setEnabled(false);
            cmdGuardar.setEnabled(false);
            txtObservaciones.setEditable(false);
        }
        if (serv.getEstado() == 0) {
            txtCosto.setEditable(true);
            lblDevuelto.setVisible(false);
            cmdEntregar.setVisible(true);
            cmdAnular.setVisible(false);
            txtObservaciones.setEditable(true);
        } else if (serv.getEstado() == 1) {
            txtCosto.setEditable(false);
            lblDevuelto.setVisible(true);
            cmdEntregar.setVisible(false);
            cmdAnular.setVisible(true);
        } else {
            txtCosto.setEditable(false);
            lblDevuelto.setVisible(true);
            cmdEntregar.setVisible(false);
            cmdAnular.setVisible(false);
            lblDevuelto.setText("Anulado");
        }
        userPanel.setLayout(new GridLayout(2, 2));

//Labels for the textfield components        
//Add the components to the JPanel        
        userPanel.add(usernameLbl);
        userPanel.add(username);
        userPanel.add(passwordLbl);
        userPanel.add(passwordFld);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtNumero = new javax.swing.JTextField();
        txtCedula = new javax.swing.JTextField();
        txtCliente = new javax.swing.JTextField();
        txtNumSerie = new javax.swing.JTextField();
        txtChip = new javax.swing.JTextField();
        txtMemoria = new javax.swing.JTextField();
        txtFecha = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        cmdGuardar = new javax.swing.JButton();
        cmdCancelar = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtDatos = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtFallo = new javax.swing.JTextArea();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtObservaciones = new javax.swing.JTextArea();
        jLabel10 = new javax.swing.JLabel();
        lblCosto = new javax.swing.JLabel();
        txtCosto = new javax.swing.JTextField();
        cmdEntregar = new javax.swing.JButton();
        lblDevuelto = new javax.swing.JLabel();
        cmdAnular = new javax.swing.JButton();
        cmdImprimir = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
        jLabel1.setText("SOLICITUD DE SERVICIO TECNICO");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(51, 51, 51));
        jLabel2.setText("Numero:");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(51, 51, 51));
        jLabel3.setText("Cedula:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(51, 51, 51));
        jLabel4.setText("Cliente:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(51, 51, 51));
        jLabel5.setText("Num Serie:");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(51, 51, 51));
        jLabel6.setText("Chip:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(51, 51, 51));
        jLabel7.setText("Memoria:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(51, 51, 51));
        jLabel8.setText("Fecha:");

        txtNumero.setEditable(false);
        txtNumero.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtNumeroKeyReleased(evt);
            }
        });

        txtCedula.setEnabled(false);

        txtCliente.setEnabled(false);

        txtChip.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtChipActionPerformed(evt);
            }
        });

        txtFecha.setEditable(false);

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(51, 51, 51));
        jLabel11.setText("Datos del Equipo:");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(51, 51, 51));
        jLabel9.setText("Fallo Reportado:");

        cmdGuardar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        cmdGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/save.png"))); // NOI18N
        cmdGuardar.setText("     Guardar");
        cmdGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdGuardarActionPerformed(evt);
            }
        });

        cmdCancelar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        cmdCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/delete.png"))); // NOI18N
        cmdCancelar.setText("    Cancelar");
        cmdCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdCancelarActionPerformed(evt);
            }
        });

        txtDatos.setColumns(20);
        txtDatos.setLineWrap(true);
        txtDatos.setRows(5);
        jScrollPane3.setViewportView(txtDatos);

        txtFallo.setColumns(20);
        txtFallo.setLineWrap(true);
        txtFallo.setRows(5);
        jScrollPane4.setViewportView(txtFallo);

        txtObservaciones.setColumns(20);
        txtObservaciones.setRows(5);
        jScrollPane1.setViewportView(txtObservaciones);

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(51, 51, 51));
        jLabel10.setText("Observaciones:");

        lblCosto.setText("Costo:");

        cmdEntregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/check.png"))); // NOI18N
        cmdEntregar.setText("Entregar");
        cmdEntregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdEntregarActionPerformed(evt);
            }
        });

        lblDevuelto.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lblDevuelto.setForeground(new java.awt.Color(255, 51, 51));
        lblDevuelto.setText("Devuelto");

        cmdAnular.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/delete.png"))); // NOI18N
        cmdAnular.setText("Anular");
        cmdAnular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdAnularActionPerformed(evt);
            }
        });

        cmdImprimir.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        cmdImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/print.png"))); // NOI18N
        cmdImprimir.setText("Reimprimir");
        cmdImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdImprimirActionPerformed(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(51, 51, 51));
        jLabel12.setText("Teléfono:");

        txtTelefono.setEditable(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(101, 101, 101)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel10)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addContainerGap()
                                            .addComponent(jLabel11))
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(20, 20, 20)
                                            .addComponent(jLabel9)))
                                    .addComponent(lblCosto))
                                .addGap(5, 5, 5)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtCliente)
                            .addComponent(jScrollPane3)
                            .addComponent(jScrollPane4)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
                            .addComponent(txtCosto)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(txtFecha, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                                    .addComponent(txtChip, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtNumSerie, javax.swing.GroupLayout.Alignment.LEADING))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel12)
                                    .addComponent(jLabel7))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtMemoria)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(txtTelefono)
                                        .addGap(1, 1, 1))))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(cmdImprimir))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(116, 116, 116)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(cmdEntregar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblDevuelto)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmdAnular))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(cmdGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cmdCancelar)))))
                .addContainerGap(54, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txtNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3)))
                            .addComponent(cmdImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txtNumSerie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel5)
                                .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtChip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(txtMemoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCosto)
                    .addComponent(txtCosto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmdEntregar)
                    .addComponent(lblDevuelto)
                    .addComponent(cmdAnular))
                .addGap(7, 7, 7)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmdGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmdCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 28, 28))
        );

        setSize(new java.awt.Dimension(524, 689));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void txtChipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtChipActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtChipActionPerformed

    private void cmdGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdGuardarActionPerformed
        // TODO add your handling code here:
        Servicio.setCedulaCliente(cli);
        Servicio.setChip(txtChip.getText());
        Servicio.setMemoria(txtMemoria.getText());
        Servicio.setFecha(d);
        Servicio.setNumeroSerie(txtNumSerie.getText());
        Servicio.setDatos(txtDatos.getText());
        Servicio.setFallo(txtFallo.getText());
        Servicio.setObservaciones(txtObservaciones.getText());
        Servicio.setPaga(0d);
        Servicio.setEstado(0);
        Servicio.setIdSucursal(configuraciones.getInstance().getSucursal());
        stm.registrarServicioTecnico(Servicio);
        if (JOptionPane.showConfirmDialog(rootPane, "Guardado Correctamente\nDesea Imprimir el recibo", "Imprimir recibo", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            new CImprimir().imprimirServicioTecnico(Servicio, Servicio.getIdServicioTecnico(), configuraciones.getInstance().getConfiguracion().getImpresoraProforma());
        }
        this.dispose();
    }//GEN-LAST:event_cmdGuardarActionPerformed

    private void cmdCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCancelarActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_cmdCancelarActionPerformed

    private void txtNumeroKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNumeroKeyReleased
        // TODO add your handling code here:
        Validacion validar = new Validacion();
        validar.numeros(evt, txtNumero);
    }//GEN-LAST:event_txtNumeroKeyReleased

    private void cmdEntregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEntregarActionPerformed
        // TODO add your handling code here:
        if (JOptionPane.showConfirmDialog(rootPane, "Esta Seguro?", "Entregar Equipo", JOptionPane.YES_NO_CANCEL_OPTION) == JOptionPane.YES_OPTION) {
            double costo = 0;
            if (txtCosto.getText().length() > 0) {
                try {
                    costo = Double.parseDouble(txtCosto.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(rootPane, "Campo Costo Incorrecto", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            Servicio.setPaga(costo);
            Servicio.setObservaciones(txtObservaciones.getText());
            stm.entregarServicioTecnico(Servicio);
            VPrincipal.getInstance().cambiaCaja(configuraciones.getInstance().getDiario().getValor());
            JOptionPane.showMessageDialog(rootPane, "Se ha registrado correctamente la devolución");
            this.dispose();
        }
    }//GEN-LAST:event_cmdEntregarActionPerformed

    private void cmdAnularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAnularActionPerformed
        // TODO add your handling code here:
        if (configuraciones.getInstance().getUsuario().getRol() == 2 ) {
            int input = JOptionPane.showConfirmDialog(null, userPanel, "Ingrese el usuario y password de administrador:", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
            if(input==0)
            {
                Usuario usu = new UsuarioManager().buscarPorNombreYPassword(username.getText(), passwordFld.getText());
                if(usu==null)
                {
                    JOptionPane.showMessageDialog(rootPane, "Credenciales incorrectas","Error",JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            else
                return;
        }
        if (JOptionPane.showConfirmDialog(rootPane, "Esta Seguro?", "Anular Servicio", JOptionPane.YES_NO_CANCEL_OPTION) == JOptionPane.YES_OPTION) {
            stm.anularServicioTecnico(Servicio);
            VPrincipal.getInstance().cambiaCaja(configuraciones.getInstance().getDiario().getValor());
            JOptionPane.showMessageDialog(rootPane, "Se ha registrado correctamente la anulación");
            this.dispose();
        }
    }//GEN-LAST:event_cmdAnularActionPerformed

    private void cmdImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdImprimirActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(rootPane, "Esta seguro?", "Imprimir proforma", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION)
        {
            new CImprimir().imprimirServicioTecnico(Servicio, Servicio.getIdServicioTecnico(), configuraciones.getInstance().getConfiguracion().getImpresoraProforma());
        }
    }//GEN-LAST:event_cmdImprimirActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VServicioTecnico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VServicioTecnico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VServicioTecnico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VServicioTecnico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.out.println("Error setting native LAF: " + e);
        }
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VServicioTecnico(new Cliente()).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cmdAnular;
    private javax.swing.JButton cmdCancelar;
    private javax.swing.JButton cmdEntregar;
    private javax.swing.JButton cmdGuardar;
    private javax.swing.JButton cmdImprimir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JLabel lblCosto;
    private javax.swing.JLabel lblDevuelto;
    private javax.swing.JTextField txtCedula;
    private javax.swing.JTextField txtChip;
    private javax.swing.JTextField txtCliente;
    private javax.swing.JTextField txtCosto;
    private javax.swing.JTextArea txtDatos;
    private javax.swing.JTextArea txtFallo;
    private javax.swing.JTextField txtFecha;
    private javax.swing.JTextField txtMemoria;
    private javax.swing.JTextField txtNumSerie;
    private javax.swing.JTextField txtNumero;
    private javax.swing.JTextArea txtObservaciones;
    private javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables
}
